#include <iostream>
#include <stdio.h>
#include <cmath>
#include <string>
#include <vector>

#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>

#include "./include/file_operator.h"
#include "./include/operate.h"

int main(int argc, char **argv){
    std::vector<imu_data> imuList,imuList1;
    std::vector<imu_data> tmp_bias;
    imu_data average_bias,varience_bias;
    imu_data bias;
    //imuList=openfile("/home/feifan/Documents/kalibration/tmp.txt");
    //std::cout<<imuList.size()<<std::endl;
    for(int i=0;i<6;i++){
    imuList=openfile("/home/feifan/Documents/kalibration/"+std::to_string(i*360)+"/imu.txt");
    imuList1=openfile("/home/feifan/Documents/kalibration/"+std::to_string(i*360+180)+"/imu.txt"); 
    bias = bias_count(imuList,imuList1);
    tmp_bias.push_back(bias);
    }
    average_bias = imu_average(tmp_bias);
    varience_bias = imu_varience(average_bias,tmp_bias);
    std::cout<<"bias_average:"<<std::endl;
    printf("ax: %lf, ay: %lf\ngx: %lf, gy: %lf\n",average_bias.ax,average_bias.ay,average_bias.gx,average_bias.gy);
    std::cout<<"bias_varience:"<<std::endl;
    printf("ax: %lf, ay: %lf\ngx: %lf, gy: %lf\n",varience_bias.ax,varience_bias.ay,varience_bias.gx,varience_bias.gy);
    return 0;
}